package edu.gatech.volt2.drdoommgt.gui;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;

import edu.gatech.volt2.drdoommgt.domain.Doctor;
import javax.swing.JCheckBox;

@SuppressWarnings("serial")
public class ViewDailyAppointmentWindow extends JFrame implements IViewAppointmentView {

	JButton cancelButton;
	JButton submitButton;
	JComboBox doctorName;
	JComboBox whenMonth;
	JComboBox whenDay;
	JComboBox whenYear;
	JCheckBox chckbxNewCheckBox;

	private JPanel contentPane;
	/**
	 * Create the panel.
	 */
	public ViewDailyAppointmentWindow() {
		
		
		Calendar cal = Calendar.getInstance();
		
		
		setTitle("Dr. Doom Management");
		
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		setBounds(100, 100, 480, 323);
		contentPane.setLayout(null);

		JLabel lblNewLabel = new JLabel("View Daily Appointment");
		lblNewLabel.setBounds(10, 11, 440, 16);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblNewLabel);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(10, 55, 450, 182);
		contentPane.add(panel_1);
		panel_1.setLayout(null);
		
		JLabel lblNewLabel_1 = new JLabel("Doctor:");
		lblNewLabel_1.setBounds(6, 17, 47, 16);
		panel_1.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("On:");
		lblNewLabel_2.setBounds(6, 79, 52, 16);
		panel_1.add(lblNewLabel_2);
		
		doctorName = new JComboBox();
		doctorName.setBounds(6, 40, 170, 27);
		panel_1.add(doctorName);
		
		whenMonth = new JComboBox();
		whenMonth.setBounds(6, 107, 80, 27);
		panel_1.add(whenMonth);
		
		for ( int month=1;month<=12;month++ ){
			whenMonth.addItem(month);
			if( month == (cal.get(Calendar.MONTH)+1)){
				whenMonth.setSelectedItem(month);
			}
		}
		
		whenDay = new JComboBox();
		whenDay.setBounds(85, 107, 80, 27);
		panel_1.add(whenDay);
		
		for ( int days=1;days<=31;days++ ){
			whenDay.addItem(days);
			if( days == (cal.get(Calendar.DAY_OF_MONTH))){
				whenDay.setSelectedItem(days);
			}
		}
		
		whenYear = new JComboBox();
		whenYear.setBounds(168, 107, 85, 27);
		for (int year=2011;year<2013;year++){
			whenYear.addItem(year);
		}
		panel_1.add(whenYear);
		
		chckbxNewCheckBox = new JCheckBox("View All Appointments");
		chckbxNewCheckBox.setBounds(270, 109, 162, 23);
		panel_1.add(chckbxNewCheckBox);
		
		cancelButton = new JButton("Cancel");
		cancelButton.setBounds(364, 248, 86, 29);
		contentPane.add(cancelButton);
		
		submitButton = new JButton("Submit");
		submitButton.setBounds(15, 248, 86, 29);
		contentPane.add(submitButton);
		
	}

	public void setDoctorsList(List<Doctor> docs){
		for ( Doctor addDoc : docs ){
			doctorName.addItem(addDoc);
		}
	}
	
	@Override
	public void showSelf() {
		this.setVisible(true);
	}

	@Override
	public void addListener(ActionListener al) {
		submitButton.addActionListener(al);
		cancelButton.addActionListener(al);
	}

	@Override
	public void hideSelf() {
		this.setVisible(false);	
	}

	@Override
	public JButton getSubmitButton() {
		return submitButton;
	}

	@Override
	public JButton getCancelButton() {
		return cancelButton;
	}
	
	/**
	 * @return the doctorName
	 */
	public JComboBox getDoctorName() {
		return doctorName;
	}

	/**
	 * @return the whenMonth
	 */
	public JComboBox getWhenMonth() {
		return whenMonth;
	}

	/**
	 * @return the whenDay
	 */
	public JComboBox getWhenDay() {
		return whenDay;
	}

	/**
	 * @return the whenYear
	 */
	public JComboBox getWhenYear() {
		return whenYear;
	}

	/**
	 * @return the chckbxNewCheckBox
	 */
	public JCheckBox getChckbxNewCheckBox() {
		return chckbxNewCheckBox;
	}

	@Override
	public JComboBox getWhenTime() {
		return null;
	}

	@Override
	public JTextPane getReasonText() {
		return null;
	}


}
